import java.lang.reflect.Array;
import java.util.Arrays;
import java.util.Stack;

public class MyStack {
    public int[] elem;
    public int usedSize;

    public MyStack(){
        this.elem = new int[10];
    }

    public void push(int val) {
        if( isFull() ){
            this.elem = Arrays.copyOf(elem,2*elem.length);
        }
        elem[usedSize++] = val;
    }

    public Boolean isFull(){
        return usedSize == elem.length;
    }

    public int pop(){
        if( isEmply() ){
            return -1;
        }
        int val = elem[usedSize-1];
        usedSize--;
        return val;
    }
    public int peek(){
        if( isEmply() ){
            throw new EmptyStackException();
        }
        return elem[usedSize-1];
    }
    public Boolean isEmply(){
        return usedSize == 0;
    }
}


